import { stringify } from 'qs';
import request from '../utils/request';

export const commonGet = async params => {
  const { url, ...paramsData } = params
  return request(`${url}?${stringify(paramsData)}`, {
    method: 'GET',
  })
}

export async function getList(params) {
  return request.post('/vehicle/list', { data:  params ? { ...params, page: params.current, size: params.pageSize } : {} }).then(e => {
    return e.data || {};
  });
}

export async function getEnterList(params) {
  return request('/vehicle/enterlist', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}
export async function getEnrolledVehicle(params) {
  return request('/vehicle/enrolledlist', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

export async function findVehicleDetail(params) {
  return request(`/vehicle/finddetail/${params.vin}?tbox=${params.tbox}&pdsn=${params.pdsn}`, {
    method: 'GET',
  });
}

export async function findHistory(params) {
  return request(`/vehicle/findhistory?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function findWheelPath(params) {
  return request(`/vehicle/findwheelpath?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function exportVehicleHistory(params) {
  return request(`/vehicle/exportvehiclehistory/${params}`, {
    method: 'GET',
  });
}

export async function activeApply(params) {
  return request.post('/vehicle/activeApply', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function findVehicleApply(params) {
  return request(`/vehicle/findvehicleapply/${(params)}`, {
    method: 'GET',
  });
}

export async function addBatchVehicleActiveApply(params) {
  return request.post('/vehicle/activeApply', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
// export async function addBatchVehicleActiveApply(params) {
//   return request('/vehicle/batchactiveapply', {
//     method: 'POST',
//     body: {
//       ...params,
//     },
//   });
// }

export async function searchTboxGMDSS(params) {
  return request(`/vehicle/searchtboxgmdss?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function searchDMTboxGMDSS(params) {
  return request(`/vehicle/searchdmtboxgmdss?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function vehicleLogout(params) {
  return request(`/vehicle/vehiclelogout/${params}`, {
    method: 'GET',
  });
}

export async function bindingTbox(params) {
  return request.post('/vehicle/bindingtbox', {
    data: {
      ...params,
    },
  });
}

export async function bindingPdsn(params) {
  return request.post('/vehicle/bindingpdsn', {
    data: {
      ...params,
    },
  });
}

export async function add(params) {
  return request.post('/vehicle/save', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function edit(params) {
  return request.post(`/vehicle/edit/${params.sid}`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function findProfile(params) {
  return request(`/vehicle/findprofile/${params}`, {
    method: 'GET',
  });
}

export async function findTboxSmsBySmsId(params) {
  return request(`/vehicle/findtboxsms/${params}`, {
    method: 'GET',
  });
}

export async function simulateDownTboxLogs(params) {
  return request('/vehicle/simulatedowntboxlogs', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

export async function simulateUpTboxLogs(params) {
  return request('/vehicle/simulateuptboxlogs', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}


export async function resendActive(params) {
  return request(`/vehicle/resendActive/${params.vin}/${params.type}`, {
    method: 'GET',
  });
}

export async function findVerificationCodeByVin(params) {
  return request(`/vehicle/getverifcodebyvin?${stringify(params)}`, {
    method: 'GET',
  });
}


export async function checkVerifCode(params) {
  return request(`/vehicle/checkverifcode?${stringify(params)}`, {
    method: 'GET',
  });
}

/**
 * c53根据VIN查询车主信息，若存在车主信息则发起激活流程
 * @param params
 * @returns {Promise.<void>}
 */
export async function getAuthInfo(params) {
  return request(`/vehicle/getauthinfo/${params}`, {
    method: 'GET',
  });
}

/**
 * c53激活
 * @param params
 * @returns {Promise.<void>}
 */
export async function authAndActivation(params) {
  return request('/vehicle/authandactivation', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}


/**
 * c53重新提交审核
 * @param params
 * @returns {Promise.<void>}
 */
export async function reAuth(params) {
  return request(`/vehicle/reauth/${params}`, {
    method: 'GET',
  });
}

/**
 * C53
 * @param params
 * @returns {Promise.<void>}
 */
export async function searchTboxBusiGMDSS(params) {
  return request(`/vehicle/searchtboxbusigmdss?${stringify(params)}`, {
    method: 'GET',
  });
}

/**
 * C53
 * @param params
 * @returns {Promise.<void>}
 */
export async function searchDMTboxBusiGMDSS(params) {
  return request(`/vehicle/searchdmtboxbusigmdss?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function reSendActiveInfo(params) {
  return request(`/vehicle/resendactiveinfo?${stringify(params)}`, {
    method: 'GET',
  });
}


/**
 * c53注销
 * @param params
 * @returns {Promise.<void>}
 */
export async function vehicleRelieve(params) {
  return request(`/vehicle/vehiclerelieve/${params}`, {
    method: 'GET',
  });
}

/**
 * c53质检车注销
 * @param params
 * @returns {Promise.<void>}
 */
export async function vehicleFactoryLogout(params) {
  return request(`/vehicle/vehiclefactorylogout/${params}`, {
    method: 'GET',
  });
}

/**
 * 北汽经销商车辆查询
 * @param params
 * @returns {Promise.<void>}
 */
export async function searchVehicleBaic(params) {
  return request(`/vehicle/vehiclebaicquery/${params}`, {
    method: 'GET',
  });
}

/**
 * 北汽经销商车辆查询列表
 * @param params
 * @returns {Promise.<void>}
 */
export async function searchVehicleBaicDealer(params) {
  return request('/vehicle/vehiclebaicdealerlist', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

/**
 * 五菱车况仪表
 */
export async function getVehicleInstrument(params) {
  return request('/vehicle/getvehicleinstrumentv2', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}
/**
 * 根据vin获取车辆iccid
 */
export async function getIccid(params) {
  return request(`/vehicle/getSimProfileByVin/${(params)}`, {
    method: 'GET',
  });
}
/**
 * S31调拨历史
 */
export async function queryList(params) {
  return request(`/vehicle/movement/page?${stringify(params)}`, {
    method: 'GET',
  });
}









